<%@ page import="coe.pumbaa.Event" %>
<%@ page import="org.joda.time.Instant" %>


<!doctype html>
<html>
<head>
    <meta name="layout" content="PumbaaLayout">
    <g:set var="entityName" value="${message(code: 'event.label', default: 'Event')}"/>
    <title><g:message code="default.show.label" args="[entityName]"/></title>

    <r:require module="calendar" />

</head>

<body>
  <section id="main" class="column">
    <pumbaa:alert />
    <article class="module width_full">
    <header><h3>${eventInstance?.title}</h3></header>
    <g:if test="${flash.message}">
        <div class="message" role="status">${flash.message}</div>
    </g:if>
<fieldset class="form">
            <fieldset style="width: 80%; float: left; margin-right: 3%; margin-left: 3%;">
              <label>When</label>
                <g:formatDate date="${new Instant(occurrenceStart).toDate()}" format="E, MMM d, hh:mma"/>  –
                <g:formatDate date="${new Instant(occurrenceEnd).toDate()}" format="E, MMM d, hh:mma"/>
            </fieldset><br />

       
        <g:if test="${eventInstance?.location}">
          <fieldset style="width: 80%; float: left; margin-right: 3%; margin-left: 3%;">
            <label>Location</label>
                <span id="location-label" class="property-label"><g:message code="event.location.label"
                                                                            default="Location"/></span>
                <span class="property-value" aria-labelledby="location-label"><g:fieldValue bean="${eventInstance}"
                                                                                            field="location"/></span>
          </fieldset><br/>
        </g:if>

        <g:if test="${eventInstance?.description}">
            <fieldset style="width: 80%; float: left; margin-right: 3%; margin-left: 3%;">
              <label>Description</label>

                <span class="property-value" aria-labelledby="description-label"><g:fieldValue bean="${eventInstance}"
                                                                                               field="description"/></span>

            </fieldset> <br/>
        </g:if>

  </fieldset>
    <g:form>
        <fieldset class="buttons">
            <g:hiddenField name="id" value="${eventInstance?.id}"/>

            <g:hiddenField name="occurrenceStart" value="${occurrenceStart}" />
            <g:hiddenField name="occurrenceEnd" value="${occurrenceEnd}" />

            <g:actionSubmit class="edit" action="edit"
                            value="${message(code: 'default.button.edit.label', default: 'Edit')}"/>
            <g:actionSubmit class="delete ${eventInstance.isRecurring ? 'recurring' : ''}" action="delete"
                            value="${message(code: 'default.button.delete.label', default: 'Delete')}" />
        </fieldset>
    </g:form>

    <g:if test="${eventInstance.isRecurring}">
        <g:render template="deletePopup" model="model" />
    </g:if>

    </article>
    </<section>
</body>
</html>
